package com.chixing.ih.module.programmer.controller;

import com.chixing.ih.json.ResponseData;
import com.chixing.ih.module.programmer.pojo.Work;
import com.chixing.ih.module.programmer.service.IWorkService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-10-01
 * Time: 22:14
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/work")
@Api(tags = "程序员模块工作设置相关Api")
public class WorkController {

    @Autowired
    IWorkService workService;

    /**
     * desc:保存工作设置接口
     *
     * @param work
     * @return
     */
    @ApiOperation(value = "保存工作设置接口", notes = "保存工作设置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = " programmerId", value = "程序员id", required = true, dataType = "long"),
            @ApiImplicitParam(name = "WDBT", value = "日常工作开始时间", dataType = "date"),
            @ApiImplicitParam(name = "WDET", value = "日常工作结束时间", dataType = "date"),
            @ApiImplicitParam(name = "WWBT", value = "周末工作开始时间", dataType = "date"),
            @ApiImplicitParam(name = "WWET", value = "周末工作结束时间", dataType = "date"),
            @ApiImplicitParam(name = "weeklyTime", value = "工作时长", dataType = "int"),
            @ApiImplicitParam(name = "salary", value = "日新", dataType = "double"),
            @ApiImplicitParam(name = "workWay", value = "工作方式", dataType = "int"),
            @ApiImplicitParam(name = "regionProvince", value = "可工作地区省份", dataType = "string"),
            @ApiImplicitParam(name = "regionCity", value = "可工作地区城市", dataType = "string"),
            @ApiImplicitParam(name = "workStatus", value = "接单状态", dataType = "int"),

    })
    @ApiResponses({
            @ApiResponse(code = 201, message = "保存成功"),
            @ApiResponse(code = 400, message = "保存失败"),
    })
    @PutMapping("/work")
    public Map<String, Object> saveWork(@RequestBody Work work) {
        boolean flag = workService.saveWork(work);
        if (flag)
            return ResponseData.REP_CREATED_SUCCESS();
        else
            return ResponseData.REP_INVALID_ERROR();

    }


    /**
     * desc:查看工作设置接口
     *
     * @param programmerId
     * @return
     */
    @ApiOperation(value = "查看工作设置接口", notes = "保存工作设置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = " programmerId", value = "程序员id", required = true, dataType = "long"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "查询失败")

    })

    @GetMapping("/work/{programmerId}")
    public Map<String, Object> getWork(@PathVariable("programmerId") long programmerId) {
        Work work = workService.getWork(programmerId);
        return ResponseData.REP_GET_SUCCESS(work);


    }


}





